<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        new Promise((resolve, reject) => {
            console.log('开始请求A数据。。。');
            try {
                setTimeout(() => {
                    console.log('请求A数据成功');
                    const username = {
                        user: 'xiaoxinyan'
                    }
                    resolve(username)
                }, 1500)
            } catch (e) {
                reject(e.message)
            }

        })
            .then((value) => {
                return new Promise((resolve, reject) => {
                    console.log('开始请求b数据。。。');
                    try {
                        setTimeout(() => {
                            console.log('请求b数据成功');
                            const age = {
                                age: 18
                            }
                            resolve({
                                ...value,
                                ...age
                            })//Object.assign({},value,age)
                        }, 1500)
                    } catch (e) {
                        reject(e.message)
                    }
                })
            })

            .then((value) => {
                return new Promise((resolve, reject) => {
                    console.log('开始请求c数据。。。');
                    try {
                        throw new Error('网络异常')
                        setTimeout(() => {
                            console.log('请求c数据成功');
                            const sex = {
                                sex: '女'
                            }
                            resolve({
                                ...value,
                                ...sex,
                            })//Object.assign({},value,sex)
                        }, 1500)
                    } catch (e) {
                        reject(e.message)
                    }

                })
            })
            .then(value => {
                //处理value
                console.log(value);
            })
            .catch((reason) => {
                console.log('异常');
            })

    </script>
</body>

</html>